package com.example.administrator.foodrowfresh.jiao.modle;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import org.json.JSONException;
import org.json.JSONObject;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/5/3.
 */
public class PromotionModel {

    /**
     * success : 1
     * data : {"activity":[{"RowId":1,"id":245,"LinkUrl":"","title":"粽享滋味","BeginTime":"2016-04-21 09:01:12.000","begin_time":"1461200472","status":1,"Description":null,"image":"http://images4sh-app.34580.com/images/ProductImages/SH_Image_19808_jpeg_640.jpeg"},{"RowId":2,"id":247,"LinkUrl":"","title":"品质生鲜 底价答谢","BeginTime":"2016-04-26 00:00:00.000","begin_time":"1461600000","status":3,"Description":null,"image":"http://images4sh-app.34580.com/images/ProductImages/SH_Image_19869_jpeg_640.jpeg"},{"RowId":3,"id":248,"LinkUrl":"","title":"美味福利 礼遇全城","BeginTime":"2016-04-26 00:00:00.000","begin_time":"1461600000","status":3,"Description":null,"image":"http://images4sh-app.34580.com/images/ProductImages/SH_Image_19870_jpeg_640.jpeg"},{"RowId":4,"id":246,"LinkUrl":"","title":"闽龙达南北干货专题","BeginTime":"2016-04-22 00:00:00.000","begin_time":"1461254400","status":3,"Description":null,"image":"http://images4sh-app.34580.com/images/ProductImages/SH_Image_19785_jpeg_640.jpeg"},{"RowId":5,"id":244,"LinkUrl":"","title":"苏牛全场8折","BeginTime":"2016-04-21 00:00:00.000","begin_time":"1461168000","status":3,"Description":null,"image":"http://images4sh-app.34580.com/images/ProductImages/SH_Image_19726_jpeg_640.jpeg"},{"RowId":6,"id":243,"LinkUrl":"","title":"食用油活动专题","BeginTime":"2016-04-16 00:00:00.000","begin_time":"1460736000","status":3,"Description":null,"image":"http://images4sh-app.34580.com/images/ProductImages/SH_Image_19563_jpeg_640.jpeg"},{"RowId":7,"id":241,"LinkUrl":"","title":"时令鲜 超值价","BeginTime":"2016-04-14 00:00:00.000","begin_time":"1460563200","status":3,"Description":null,"image":"http://images4sh-app.34580.com/images/ProductImages/SH_Image_19445_jpeg_640.jpeg"},{"RowId":8,"id":242,"LinkUrl":"","title":"爆款直降嗨翻天","BeginTime":"2016-04-14 00:00:00.000","begin_time":"1460563200","status":3,"Description":null,"image":"http://images4sh-app.34580.com/images/ProductImages/SH_Image_19446_jpeg_640.jpeg"},{"RowId":9,"id":240,"LinkUrl":"","title":"臻品之选 至上之礼","BeginTime":"2016-04-11 15:08:31.000","begin_time":"1460358511","status":3,"Description":null,"image":"http://images4sh-app.34580.com/images/ProductImages/SH_Image_19360_jpeg_640.jpeg"},{"RowId":10,"id":237,"LinkUrl":"","title":"水产肉禽齐聚惠","BeginTime":"2016-04-07 00:00:00.000","begin_time":"1459958400","status":3,"Description":null,"image":"http://images4sh-app.34580.com/images/ProductImages/SH_Image_19180_jpeg_640.jpeg"}],"more":1}
     */

    private int success;
    /**
     * activity : [{"RowId":1,"id":245,"LinkUrl":"","title":"粽享滋味","BeginTime":"2016-04-21 09:01:12.000","begin_time":"1461200472","status":1,"Description":null,"image":"http://images4sh-app.34580.com/images/ProductImages/SH_Image_19808_jpeg_640.jpeg"},{"RowId":2,"id":247,"LinkUrl":"","title":"品质生鲜 底价答谢","BeginTime":"2016-04-26 00:00:00.000","begin_time":"1461600000","status":3,"Description":null,"image":"http://images4sh-app.34580.com/images/ProductImages/SH_Image_19869_jpeg_640.jpeg"},{"RowId":3,"id":248,"LinkUrl":"","title":"美味福利 礼遇全城","BeginTime":"2016-04-26 00:00:00.000","begin_time":"1461600000","status":3,"Description":null,"image":"http://images4sh-app.34580.com/images/ProductImages/SH_Image_19870_jpeg_640.jpeg"},{"RowId":4,"id":246,"LinkUrl":"","title":"闽龙达南北干货专题","BeginTime":"2016-04-22 00:00:00.000","begin_time":"1461254400","status":3,"Description":null,"image":"http://images4sh-app.34580.com/images/ProductImages/SH_Image_19785_jpeg_640.jpeg"},{"RowId":5,"id":244,"LinkUrl":"","title":"苏牛全场8折","BeginTime":"2016-04-21 00:00:00.000","begin_time":"1461168000","status":3,"Description":null,"image":"http://images4sh-app.34580.com/images/ProductImages/SH_Image_19726_jpeg_640.jpeg"},{"RowId":6,"id":243,"LinkUrl":"","title":"食用油活动专题","BeginTime":"2016-04-16 00:00:00.000","begin_time":"1460736000","status":3,"Description":null,"image":"http://images4sh-app.34580.com/images/ProductImages/SH_Image_19563_jpeg_640.jpeg"},{"RowId":7,"id":241,"LinkUrl":"","title":"时令鲜 超值价","BeginTime":"2016-04-14 00:00:00.000","begin_time":"1460563200","status":3,"Description":null,"image":"http://images4sh-app.34580.com/images/ProductImages/SH_Image_19445_jpeg_640.jpeg"},{"RowId":8,"id":242,"LinkUrl":"","title":"爆款直降嗨翻天","BeginTime":"2016-04-14 00:00:00.000","begin_time":"1460563200","status":3,"Description":null,"image":"http://images4sh-app.34580.com/images/ProductImages/SH_Image_19446_jpeg_640.jpeg"},{"RowId":9,"id":240,"LinkUrl":"","title":"臻品之选 至上之礼","BeginTime":"2016-04-11 15:08:31.000","begin_time":"1460358511","status":3,"Description":null,"image":"http://images4sh-app.34580.com/images/ProductImages/SH_Image_19360_jpeg_640.jpeg"},{"RowId":10,"id":237,"LinkUrl":"","title":"水产肉禽齐聚惠","BeginTime":"2016-04-07 00:00:00.000","begin_time":"1459958400","status":3,"Description":null,"image":"http://images4sh-app.34580.com/images/ProductImages/SH_Image_19180_jpeg_640.jpeg"}]
     * more : 1
     */

    private DataBean data;

    public static PromotionModel objectFromData(String str) {

        return new Gson().fromJson(str, PromotionModel.class);
    }

    public static PromotionModel objectFromData(String str, String key) {

        try {
            JSONObject jsonObject = new JSONObject(str);

            return new Gson().fromJson(jsonObject.getString(str), PromotionModel.class);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        return null;
    }

    public static List<PromotionModel> arrayPromotionModelFromData(String str) {

        Type listType = new TypeToken<ArrayList<PromotionModel>>() {
        }.getType();

        return new Gson().fromJson(str, listType);
    }

    public static List<PromotionModel> arrayPromotionModelFromData(String str, String key) {

        try {
            JSONObject jsonObject = new JSONObject(str);
            Type listType = new TypeToken<ArrayList<PromotionModel>>() {
            }.getType();

            return new Gson().fromJson(jsonObject.getString(str), listType);

        } catch (JSONException e) {
            e.printStackTrace();
        }

        return new ArrayList();


    }

    public int getSuccess() {
        return success;
    }

    public void setSuccess(int success) {
        this.success = success;
    }

    public DataBean getData() {
        return data;
    }

    public void setData(DataBean data) {
        this.data = data;
    }

    public static class DataBean {
        private int more;
        /**
         * RowId : 1
         * id : 245
         * LinkUrl :
         * title : 粽享滋味
         * BeginTime : 2016-04-21 09:01:12.000
         * begin_time : 1461200472
         * status : 1
         * Description : null
         * image : http://images4sh-app.34580.com/images/ProductImages/SH_Image_19808_jpeg_640.jpeg
         */

        private List<ActivityBean> activity;

        public static DataBean objectFromData(String str) {

            return new Gson().fromJson(str, DataBean.class);
        }

        public static DataBean objectFromData(String str, String key) {

            try {
                JSONObject jsonObject = new JSONObject(str);

                return new Gson().fromJson(jsonObject.getString(str), DataBean.class);
            } catch (JSONException e) {
                e.printStackTrace();
            }

            return null;
        }

        public static List<DataBean> arrayDataBeanFromData(String str) {

            Type listType = new TypeToken<ArrayList<DataBean>>() {
            }.getType();

            return new Gson().fromJson(str, listType);
        }

        public static List<DataBean> arrayDataBeanFromData(String str, String key) {

            try {
                JSONObject jsonObject = new JSONObject(str);
                Type listType = new TypeToken<ArrayList<DataBean>>() {
                }.getType();

                return new Gson().fromJson(jsonObject.getString(str), listType);

            } catch (JSONException e) {
                e.printStackTrace();
            }

            return new ArrayList();


        }

        public int getMore() {
            return more;
        }

        public void setMore(int more) {
            this.more = more;
        }

        public List<ActivityBean> getActivity() {
            return activity;
        }

        public void setActivity(List<ActivityBean> activity) {
            this.activity = activity;
        }

        public static class ActivityBean {
            private int RowId;
            private int id;
            private String LinkUrl;
            private String title;
            private String BeginTime;
            private String begin_time;
            private int status;
            private Object Description;
            private String image;

            public static ActivityBean objectFromData(String str) {

                return new Gson().fromJson(str, ActivityBean.class);
            }

            public static ActivityBean objectFromData(String str, String key) {

                try {
                    JSONObject jsonObject = new JSONObject(str);

                    return new Gson().fromJson(jsonObject.getString(str), ActivityBean.class);
                } catch (JSONException e) {
                    e.printStackTrace();
                }

                return null;
            }

            public static List<ActivityBean> arrayActivityBeanFromData(String str) {

                Type listType = new TypeToken<ArrayList<ActivityBean>>() {
                }.getType();

                return new Gson().fromJson(str, listType);
            }

            public static List<ActivityBean> arrayActivityBeanFromData(String str, String key) {

                try {
                    JSONObject jsonObject = new JSONObject(str);
                    Type listType = new TypeToken<ArrayList<ActivityBean>>() {
                    }.getType();

                    return new Gson().fromJson(jsonObject.getString(str), listType);

                } catch (JSONException e) {
                    e.printStackTrace();
                }

                return new ArrayList();


            }

            public int getRowId() {
                return RowId;
            }

            public void setRowId(int RowId) {
                this.RowId = RowId;
            }

            public int getId() {
                return id;
            }

            public void setId(int id) {
                this.id = id;
            }

            public String getLinkUrl() {
                return LinkUrl;
            }

            public void setLinkUrl(String LinkUrl) {
                this.LinkUrl = LinkUrl;
            }

            public String getTitle() {
                return title;
            }

            public void setTitle(String title) {
                this.title = title;
            }

            public String getBeginTime() {
                return BeginTime;
            }

            public void setBeginTime(String BeginTime) {
                this.BeginTime = BeginTime;
            }

            public String getBegin_time() {
                return begin_time;
            }

            public void setBegin_time(String begin_time) {
                this.begin_time = begin_time;
            }

            public int getStatus() {
                return status;
            }

            public void setStatus(int status) {
                this.status = status;
            }

            public Object getDescription() {
                return Description;
            }

            public void setDescription(Object Description) {
                this.Description = Description;
            }

            public String getImage() {
                return image;
            }

            public void setImage(String image) {
                this.image = image;
            }
        }
    }
}
